<html>
<head><meta charset="utf-8"><title>mutability-lint · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html">mutability-lint</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="126366844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126366844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126366844">(May 10 2018 at 14:21)</a>:</h4>
<p><span class="user-mention" data-user-id="116108">@Keith Yeung</span> do you think you'll have a chance to check out <a href="https://github.com/rust-lang/rust/issues/50463" target="_blank" title="https://github.com/rust-lang/rust/issues/50463">https://github.com/rust-lang/rust/issues/50463</a> ?</p>



<a name="126372112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126372112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126372112">(May 10 2018 at 16:19)</a>:</h4>
<p>I was indeed looking at it yesterday</p>



<a name="126372119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126372119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126372119">(May 10 2018 at 16:19)</a>:</h4>
<p>The fix I envisioned in there doesn't actually work</p>



<a name="126372180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126372180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126372180">(May 10 2018 at 16:20)</a>:</h4>
<p>ok, I've not looked at all</p>



<a name="126372857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126372857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126372857">(May 10 2018 at 16:35)</a>:</h4>
<p>Oh, it just hit me</p>



<a name="126372879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126372879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126372879">(May 10 2018 at 16:35)</a>:</h4>
<p>The problem is likely because we treat the first assignment as initialization</p>



<a name="126384684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384684">(May 10 2018 at 21:07)</a>:</h4>
<p>huh, so we treat mutable fn args as uninitialized at the beginning?</p>



<a name="126384691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384691">(May 10 2018 at 21:07)</a>:</h4>
<p>we have a "simple case" (no pattern) and a more complex case (pattern)</p>



<a name="126384694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384694">(May 10 2018 at 21:07)</a>:</h4>
<p>mut probably gets treated like the latter?</p>



<a name="126384734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384734">(May 10 2018 at 21:08)</a>:</h4>
<p>sometimes there are things like <code>(a, b): (Foo, Bar)</code></p>



<a name="126384754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384754">(May 10 2018 at 21:08)</a>:</h4>
<p>in which case we have the <em>actual argument</em>, which has type <code>(Foo, Bar)</code></p>



<a name="126384766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126384766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126384766">(May 10 2018 at 21:08)</a>:</h4>
<p>and we then destructure it into locals for <code>a</code> and <code>b</code></p>



<a name="126505288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126505288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126505288">(May 13 2018 at 18:12)</a>:</h4>
<p>so i've switched from checking <code>MaybeInitializedPlaces</code> into <code>EverInitializedPlaces</code> in the mutability lint analysis, and the test cases all seem to pass</p>



<a name="126505290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126505290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126505290">(May 13 2018 at 18:13)</a>:</h4>
<p>here's a complimentary PR to go with it: <a href="https://github.com/rust-lang/rust/pull/50697" target="_blank" title="https://github.com/rust-lang/rust/pull/50697">https://github.com/rust-lang/rust/pull/50697</a></p>



<a name="126529509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126529509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126529509">(May 14 2018 at 09:19)</a>:</h4>
<p>ok :) I don't remember well enough to say if that makes sense but I can sort of imagine why it would</p>



<a name="126558572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126558572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126558572">(May 14 2018 at 21:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> you said that we'd need another unit test for testing out the changes in the <code>WriteKind::MutableBorrow(BorrowKind::Unique)</code> branch, what kind of code generates this MIR statement?</p>



<a name="126583825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126583825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126583825">(May 15 2018 at 09:39)</a>:</h4>
<p><code>BorrowKind::Unique</code> arises from certain kinds of free variables in closures</p>



<a name="126583880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126583880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126583880">(May 15 2018 at 09:40)</a>:</h4>
<p>I'll try to set aside time to make an example later today</p>



<a name="126659262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126659262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126659262">(May 16 2018 at 18:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> looks like someone is depending on the fix, do you know how to create a test case that you mentioned?</p>



<a name="126659424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126659424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126659424">(May 16 2018 at 18:53)</a>:</h4>
<p>if you're too busy, i can just remove that change altogether</p>



<a name="126690953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126690953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126690953">(May 17 2018 at 10:22)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="116108">@Keith Yeung</span> sorry it took me so long to get back around to this. I posted a comment (some might say a shortish essay) on the PR, <a href="https://github.com/rust-lang/rust/pull/50697#issuecomment-389819434" target="_blank" title="https://github.com/rust-lang/rust/pull/50697#issuecomment-389819434">here</a></p>



<a name="126690964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126690964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126690964">(May 17 2018 at 10:23)</a>:</h4>
<p>Oh I missed your followup comment where you suggested removing the change. That is actually what I ended up coming around to by the end of writing that comment on the PR. So yes, removing that part of the change is probably best at this point.</p>



<a name="126709282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126709282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126709282">(May 17 2018 at 17:42)</a>:</h4>
<p>I basically added that line because I recall from a previous conversation on a GH issue that you mentioned that we were supposed to have this check there</p>



<a name="126713732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126713732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126713732">(May 17 2018 at 19:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span>  ok, i removed that part of the change, can either you or <span class="user-mention" data-user-id="116009">@nikomatsakis</span> approve it? <a href="https://github.com/rust-lang/rust/pull/50697" target="_blank" title="https://github.com/rust-lang/rust/pull/50697">https://github.com/rust-lang/rust/pull/50697</a></p>



<a name="126713748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126713748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126713748">(May 17 2018 at 19:15)</a>:</h4>
<p>thanks!</p>



<a name="126906750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/mutability-lint/near/126906750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Keith Yeung <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/mutability-lint.html#126906750">(May 22 2018 at 04:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> i forgot to add a <code>break</code> statement in the previous PR, and i have a new one adding it: <a href="https://github.com/rust-lang/rust/pull/50958" target="_blank" title="https://github.com/rust-lang/rust/pull/50958">https://github.com/rust-lang/rust/pull/50958</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>